package com.gxuwz.leaveSystem.service;

import com.gxuwz.leaveSystem.dao.LeaveDao;
import com.gxuwz.leaveSystem.entity.Leave;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LeaveService {

    private LeaveDao leaveDao;
    public void setLeaveDao(LeaveDao leaveDao) {
        this.leaveDao = leaveDao;
    }

    /**
     * 添加
     * @param leave
     * @return 整数
     */
    public int addLeave(Leave leave) {
        return leaveDao.addLeave(leave);
    }

    /**
     * 修改
     * @param leave
     * @return 整数
     */
    public int updateLeave(Leave leave) {
        return leaveDao.updateLeave(leave);
    }

    /**
     * 删除
     * @param leaveID
     * @return 整数
     */
    public int deleteLeave(String leaveID) {
        return leaveDao.deleteLeave(leaveID);
    }

    /**
     * 根据id查询
     * @param leaveID
     * @return leave类型的记录
     */
    public Leave getLeaveById(String leaveID) {
        return leaveDao.getLeaveById(leaveID);
    }

    /**
     * 查询所有
     * @return 返回leave所有记录
     */
    public List<Leave> getAllLeaves() {
        return leaveDao.getAllLeaves();
    }

    /**
     * 根据关键字搜索
     * @param keyword
     * @return 列表
     */
    public List<Leave> leavesSearch(String keyword){
        return leaveDao.search(keyword);
    }
}
